package com.example.springdemo5;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

@RestController
@RequestMapping("calc")
public class CalcController {
    @RequestMapping("/sum")
    public String sum(Integer num1, Integer num2) {
        if(num1 == null && num2 == null) {
            return "计算结果：0";
        }
        if(num1 == null || num2 == null) {
            String ret = (num1 == null ? num2 : num1) + " " ;
            return "计算结果:" + ret;
        }
        Integer sum = num1 + num2;
        return "计算结果：" + sum;
    }
}
